package com.ht.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ht.dto.User;
import com.ht.mapper.UserMapper;
import com.ht.service.IUserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 代齐园
 * @since 2022-05-24
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper,User> implements IUserService {
    @Resource
    private UserMapper userMapper;

    @Override
    public void registerUser(User user) {
        userMapper.insert(user);
    }

    @Override
    public void updatePassword(User user) {
        userMapper.updateById(user);
    }

    @Override
    public void deleteByIdPhone(String phoneNum) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("phone",phoneNum);
        User user = userMapper.selectOne(queryWrapper);//根据手机号查询
        userMapper.deleteById(user.getId());
    }

    @Override
    public User getBalance(User user) {
        User user1 = userMapper.selectById(user.getId());
        return user1;
    }
}